/*
 * File:   762.cpp
 * Author: xerxes
 *
 * Created on September 16, 2011, 3:59 PM
 *
 * I have not failed, I have just found 10000 ways that won't work.
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}

int n;
map<string, int > id;
map<int, string > revid;
vector< VI > path;
VI vis;
string ss;

inline void Read() {
    id.clear();
    revid.clear();
    string s1,s2;
    vector< pair<string,string> > pp;
    int x=0;
    fo(i,0,n){
        cin>>s1>>s2;
        if( !id.count(s1) ){
            id[ s1 ] = x;
            revid[ x ] = s1;
            ++x;
        }
        if( !id.count(s2) ){
            id[ s2 ] = x;
            revid[ x ] = s2;
            ++x;
        }
        pp.pb( mk(s1,s2) );
    }

    int tot = SZ(id);
    
    vis.assign(tot+5,0);
    path.assign(tot+5, VI() );

    fo(i,0,n){
        int id1 = id[ pp[i].f ];
        int id2 = id[ pp[i].s ];
        path[ id1].pb(id2);
        path[ id2].pb(id1);
    }
    
}

inline void Print(VI &vi){
    for(int i=0,j=SZ(vi); i+1<j;i+=1 ){
        cout<< revid[ vi[i] ] <<" "<< revid[ vi[i+1] ]<<"\n";
    }
}
inline void bfs(int sx, int sy){
    if( sx==sy ){
        cout<<"\n";
        return ;
    }
    queue< pair<int, VI > > q;
    VI tmp;
    tmp.pb(sx);
    q.push( mk(sx,tmp) );
    vis[sx]=1;
    
    while( !q.empty() ){
        pair<int, VI > prev = q.front();
        q.pop();


        for(int i=0,j=SZ(path[prev.f]); i<j; ++i ){
            int son = path[prev.f][i];
            if( vis[son] )continue;
            VI cur = prev.s;
            cur.pb(son);
            if( son==sy ){
                Print( cur );
                return ;
            }
            q.push( mk(son,cur) );
            vis[son]=1;
        }
    }


    cout<<"No route\n";
}

inline void Proc() {
    string s1,s2;
    cin>>s1>>s2;
    if(!id.count(s1) || !id.count(s2)){
        cout<<"No route\n";
        return ;
    }
    int id1 = id[ s1 ];
    int id2 = id[ s2 ];
    bfs(id1,id2);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in", "rt", stdin);
#endif
    ss="";
    while( scanf("%d",&n)==1 ){
        Read();
        cout<<ss;
        Proc();
        ss="\n";
    }

    return 0;
}


